/*
 * Created on Sep 16, 2005
 *La classe Lock realizza un monitor, usato dai thread che compongono 
 *il Taxi per coordinare le loro azioni.
 *
 */
package eTaxi;

/**
 * @author luisi
 * 
 * 
 */
public class Lock {

    private boolean lock;

    public Lock() {
        this.lock = true;
    }

    public synchronized boolean go() {

        while (lock) {
            try {
                wait();

            }

            catch (InterruptedException e) {
            }
        }

        return lock;
    }

    public synchronized void setLock(boolean b) {
        this.lock = b;
        notifyAll();
    }

    public synchronized boolean get() {
        return lock;
    }

}
